﻿<Window x:Class="EncoderTester.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:et="clr-namespace:EncoderTester"
    xmlns:vc1="clr-namespace:ManagedVC1;assembly=ManagedVC1Encoder"
    xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
    Title="Window1" Height="600" Width="700">
    <Window.Resources>        
        <Style TargetType="{x:Type RadioButton}">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="5,0,5,0" />
        </Style>
        <Style TargetType="{x:Type CheckBox}">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="0,0,10,0" />
        </Style>
        <Style TargetType="{x:Type Expander}">
            <Setter Property="Background" Value="LightGray" />
        </Style>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Margin" Value="0,0,0,3" />
        </Style>
        <Style TargetType="{x:Type Slider}">
            <Setter Property="Foreground" Value="Black" />
            <Setter Property="TickPlacement" Value="Both" />
            <Setter Property="AutoToolTipPlacement" Value="TopLeft" />
            <Setter Property="TickFrequency" Value="1" />
            <Setter Property="AutoToolTipPrecision" Value="0" />
            <Setter Property="IsSnapToTickEnabled" Value="True" />
            <Setter Property="Margin" Value="0,0,0,3" />
        </Style>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Margin" Value="0,0,5,3" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
        <Style TargetType="{x:Type et:NumericTextBox}">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Margin" Value="0,0,0,3" />
        </Style>
        
        <et:RadioCheckedConverter x:Key="RadioCheckedConverter" />
    </Window.Resources>
    <Grid Margin="5" x:Name="x_MainGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <DockPanel Grid.Row="0" Margin="0,0,0,10">
            <Button DockPanel.Dock="Left" Width="200" x:Name="x_LoadButton" Click="x_LoadButton_Click">Load Settings...</Button>
            <Button DockPanel.Dock="Right" HorizontalAlignment="Right" Width="200" x:Name="x_SaveButton" Click="x_SaveButton_Click">Save Settings...</Button>
        </DockPanel>        
        
        <DockPanel LastChildFill="True" Grid.Row="1" x:Name="x_InPanel">
            <Button DockPanel.Dock="Right" x:Name="x_OpenButton" Click="x_OpenButton_Click">Open...</Button>
            <TextBlock DockPanel.Dock="Left">Input</TextBlock>
            <TextBox DockPanel.Dock="Left" Text="{Binding Path=Basic.InputFile}" Margin="5,0,5,0" x:Name="x_FilenameTextBox" HorizontalAlignment="Stretch" />
        </DockPanel>
        
        <DockPanel LastChildFill="True" Grid.Row="2" Margin="0,3,0,0" x:Name="x_OutPanel">
            <Button DockPanel.Dock="Right" x:Name="x_OutOpenButton" Click="x_OutOpenButton_Click">Open...</Button>
            <TextBlock DockPanel.Dock="Left">Output</TextBlock>
            <TextBox DockPanel.Dock="Left" Text="{Binding Path=Basic.OutputFile}" Margin="5,0,5,0" x:Name="x_OutFilenameTextBox" HorizontalAlignment="Stretch" />
        </DockPanel>
        
        <StackPanel Margin="0,5,0,5" Grid.Row="3" x:Name="x_OptionsPanel">
            <Expander Header="Basic" IsExpanded="True">
                <Grid Margin="2,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    
                    <TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,5,2">Profile</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1" Margin="0,0,0,2">
                        <RadioButton GroupName="Profile" x:Name="x_SimpleProfile" IsChecked="{Binding Path=Basic.Profile, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=0}">Simple</RadioButton>
                        <RadioButton GroupName="Profile" x:Name="x_MainProfile" IsChecked="{Binding Path=Basic.Profile, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=1}">Main</RadioButton>
                        <RadioButton GroupName="Profile" x:Name="x_AdvancedProfile" IsChecked="{Binding Path=Basic.Profile, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=2}">Advanced</RadioButton>
                    </WrapPanel>
                    
                    <TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,5,2">Rate Control Mode</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Margin="0,0,0,2">
                        <RadioButton GroupName="RateControlMode" x:Name="x_OnePassCBR" IsChecked="{Binding Path=Basic.RateControlMode, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=0}">1-pass CBR</RadioButton>
                        <RadioButton GroupName="RateControlMode" x:Name="x_OnePassVBR" IsChecked="{Binding Path=Basic.RateControlMode, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=1}">1-pass VBR with fixed QP</RadioButton>
                        <RadioButton GroupName="RateControlMode" x:Name="x_TwoPassCBR" IsChecked="{Binding Path=Basic.RateControlMode, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=2}">2-pass CBR</RadioButton>
                        <RadioButton GroupName="RateControlMode" x:Name="x_TwoPassConstrainedVBR" IsChecked="{Binding Path=Basic.RateControlMode, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=3}">2-pass peak constrained VBR</RadioButton>
                        <RadioButton GroupName="RateControlMode" x:Name="x_TwoPassVBR" IsChecked="{Binding Path=Basic.RateControlMode, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=4}">2-pass unconstrained VBR</RadioButton>
                    </WrapPanel>
                </Grid>
            </Expander>
            <Expander Header="Video" IsExpanded="False">
                <Grid Margin="2,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    
                    <TextBlock Grid.Row="0" Grid.Column="0">Bit Rate</TextBlock>
                    <et:NumericTextBox Grid.Row="0" Grid.Column="1" x:Name="x_BitrateTextBox" Width="50" MaxLength="6" Minimum="1" Maximum="135000" Text="{Binding Path=Video.BitRate}" />
                    
                    <TextBlock Grid.Row="1" Grid.Column="0">Complexity Level</TextBlock>
                    <Slider Grid.Row="1" Grid.Column="1" x:Name="x_ComplexityLevelSlider" Minimum="0" Maximum="5" Value="{Binding Path=Video.ComplexityLevel}" />
                    
                    <TextBlock Grid.Row="2" Grid.Column="0">Quantization Parameter</TextBlock>
                    <Slider Grid.Row="2" Grid.Column="1" x:Name="x_QPSlider" Minimum="1" Maximum="31" Value="{Binding Path=Video.QP}" />
                    
                    <TextBlock Grid.Row="3" Grid.Column="0">Frame Rate</TextBlock>
                    <ComboBox x:Name="x_FrameRateCombo" Grid.Row="3" Grid.Column="1" Width="150" HorizontalAlignment="Left" SelectedValuePath="Rate" SelectedValue="{Binding Path=Video.FrameRate}" />
                    
                    <TextBlock Grid.Row="4" Grid.Column="0">Interlaced Source</TextBlock>
                    <CheckBox Grid.Row="4" Grid.Column="1" x:Name="x_InterlacedSource" HorizontalAlignment="Left" IsChecked="{Binding Path=Video.InterlacedSource}" />
                    
                    <TextBlock Grid.Row="5" Grid.Column="0">Maximum Key Frame Distance</TextBlock>
                    <et:NumericTextBox Grid.Row="5" Grid.Column="1" x:Name="x_MaxKeyFrameDist" Width="50" Minimum="1" Text="{Binding Path=Video.MaxKeyFrameDistance}" />
                    
                    <TextBlock Grid.Row="6" Grid.Column="0">Maximum Height</TextBlock>
                    <et:NumericTextBox Grid.Row="6" Grid.Column="1" x:Name="x_MaxHeight" MaxLength="4" Width="50" Minimum="64" Maximum="4096" Text="{Binding Path=Video.MaximumHeight}" />
                    
                    <TextBlock Grid.Row="7" Grid.Column="0">Maximum Width</TextBlock>
                    <et:NumericTextBox Grid.Row="7" Grid.Column="1" x:Name="x_MaxWidth" MaxLength="4" Width="50" Minimum="64" Maximum="4096" Text="{Binding Path=Video.MaximumWidth}" />
                    
                    <TextBlock Grid.Row="8" Grid.Column="0"># of B Frames</TextBlock>
                    <Slider Grid.Row="8" Grid.Column="1" x:Name="x_NumBFrames" Minimum="0" Maximum="8" Value="{Binding Path=Video.NumBFrames}" />
                    
                    <TextBlock Grid.Row="9" Grid.Column="0">Peak Bit Rate</TextBlock>
                    <et:NumericTextBox Grid.Row="9" Grid.Column="1" x:Name="x_PeakBitrateTextBox" Width="50" MaxLength="6" Minimum="1" Maximum="135000" Text="{Binding Path=Video.PeakBitRate}" />
                </Grid>
            </Expander>
            <Expander Header="Audio" IsExpanded="False">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <RadioButton Grid.Column="0" Margin="5,0,5,0" x:Name="x_NoAudioRadio" GroupName="Audio" IsChecked="{Binding Path=Audio.AudioProfile, Converter={StaticResource RadioCheckedConverter}}">None</RadioButton>
                    <RadioButton Grid.Column="1" Margin="5,0,5,0" x:Name="x_DefaultAudioRadio" GroupName="Audio" IsChecked="{Binding Path=Audio.AudioProfile, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=default}">Auto</RadioButton>
                    <RadioButton Grid.Column="2" Margin="5,0,5,0" x:Name="x_ProfileAudioRadio" GroupName="Audio" HorizontalContentAlignment="Stretch">
                        <Grid IsEnabled="{Binding ElementName=x_ProfileAudioRadio, Path=IsChecked}" VerticalAlignment="Center">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" DockPanel.Dock="Left" VerticalAlignment="Center">Profile</TextBlock>
                            <TextBox Grid.Column="1" DockPanel.Dock="Right" x:Name="x_ProfilePathTextBox" Text="{Binding Path=Audio.AudioProfile}" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="5,0,5,0" />
                            <Button Grid.Column="2" DockPanel.Dock="Right" x:Name="x_ProfileBrowseButton" Click="x_ProfileBrowseButton_Click">Browse...</Button>                        
                        </Grid>
                    </RadioButton>
                </Grid>
            </Expander>
            <Expander Header="Advanced" IsExpanded="False">
                <Grid Margin="2,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />                        
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Row="0" Grid.Column="0">Adaptive GOP</TextBlock>
                    <CheckBox Grid.Row="0" Grid.Column="1" x:Name="x_AdaptiveGOP" HorizontalAlignment="Left" IsChecked="{Binding Advanced.AdaptiveGOP}"  />
                    
                    <TextBlock Grid.Row="1" Grid.Column="0">B-frame Delta QP</TextBlock>
                    <Slider Grid.Row="1" Grid.Column="1" x:Name="x_BFrameQPSlider" Minimum="1" Maximum="30" Value="{Binding Advanced.BFrameDeltaQP}" />
                    
                    <TextBlock Grid.Row="2" Grid.Column="0">Closed Entry Point</TextBlock>
                    <CheckBox Grid.Row="2" Grid.Column="1" x:Name="x_ClosedEntryPoint" HorizontalAlignment="Left" IsChecked="{Binding Advanced.ClosedEntryPoint}" />
                    
                    <TextBlock Grid.Row="3" Grid.Column="0">Key Pop Reduction</TextBlock>
                    <Slider Grid.Row="3" Grid.Column="1" x:Name="x_KeyPopReduction" Minimum="0" Maximum="4" Value="{Binding Advanced.KeyPopReduction}" />
                    
                    <TextBlock Grid.Row="4" Grid.Column="0">Letter Box Present</TextBlock>
                    <CheckBox Grid.Row="4" Grid.Column="1" x:Name="x_LetterBoxPresent" HorizontalAlignment="Left" IsChecked="{Binding Advanced.LetterBoxPresent}" />
                    
                    <TextBlock Grid.Row="5" Grid.Column="0">Lookahead</TextBlock>
                    <CheckBox Grid.Row="5" Grid.Column="1" x:Name="x_Lookahead" HorizontalAlignment="Left" IsChecked="{Binding Advanced.LookAhead}" />
                    
                    <TextBlock Grid.Row="6" Grid.Column="0"># of Threads</TextBlock>
                    <Slider Grid.Row="6" Grid.Column="1" x:Name="x_NumThreads" Minimum="1" Maximum="4" Ticks="1,2,4" Value="{Binding Advanced.NumThreads}" />
                    
                    <TextBlock Grid.Row="7" Grid.Column="0" Margin="0,0,5,2">Output Mode</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="1" Margin="0,0,0,2">
                        <RadioButton GroupName="OutputType" x:Name="x_Raw" IsChecked="{Binding Path=Advanced.OutputMode, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=0}">Raw</RadioButton>
                        <RadioButton GroupName="OutputType" x:Name="x_Es" IsChecked="{Binding Path=Advanced.OutputMode, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=1}">Elementary Stream</RadioButton>
                        <RadioButton GroupName="OutputType" x:Name="x_EsSh" IsChecked="{Binding Path=Advanced.OutputMode, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=2}">Elementary Stream w/ entry point &amp; sequence start codes</RadioButton>
                    </WrapPanel>

                    <TextBlock Grid.Row="8" Grid.Column="0" Margin="0,0,5,2">Video Type</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Row="8" Grid.Column="1" Margin="0,0,0,2">
                        <RadioButton GroupName="VideoType" x:Name="x_Progressive" IsChecked="{Binding Path=Advanced.VideoType, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=0}">Progressive</RadioButton>
                        <RadioButton GroupName="VideoType" x:Name="x_InterlacedFrames" IsChecked="{Binding Path=Advanced.VideoType, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=1}">Interlaced frames</RadioButton>
                        <RadioButton GroupName="VideoType" x:Name="x_InterlacedFields" IsChecked="{Binding Path=Advanced.VideoType, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=2}">Interlaced fields</RadioButton>
                        <RadioButton GroupName="VideoType" x:Name="x_AutoFF" IsChecked="{Binding Path=Advanced.VideoType, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=3}">Auto (frame or field)</RadioButton>
                        <RadioButton GroupName="VideoType" x:Name="x_AutoFFP" IsChecked="{Binding Path=Advanced.VideoType, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=4}">Auto (frame, field, or progressive)</RadioButton>
                    </WrapPanel>
                </Grid>
            </Expander>
            <Expander Header="Motion Estimation" IsExpanded="False">
                <Grid Margin="2,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    
                    <TextBlock Grid.Column="0" Grid.Row="0" Margin="0,0,10,2">Delta Motion Vector Range Index</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="0" Margin="0,0,0,2">
                        <RadioButton HorizontalAlignment="Center" GroupName="DeltaMVRangeIndex" IsChecked="{Binding Path=MotionEstimation.DeltaMVRangeIndex, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=0}">Off</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="DeltaMVRangeIndex" IsChecked="{Binding Path=MotionEstimation.DeltaMVRangeIndex, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=1}">Horizontal</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="DeltaMVRangeIndex" IsChecked="{Binding Path=MotionEstimation.DeltaMVRangeIndex, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=2}">Vertical</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="DeltaMVRangeIndex" IsChecked="{Binding Path=MotionEstimation.DeltaMVRangeIndex, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=3}">H &amp; V</RadioButton>
                    </WrapPanel>
                    
                    <TextBlock Grid.Column="0" Grid.Row="1" Margin="0,0,10,2">Motion Search Level</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1" Margin="0,0,0,2">
                        <RadioButton HorizontalAlignment="Center" GroupName="MotionSearchLevel" IsChecked="{Binding Path=MotionEstimation.MotionSearchLevel, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=0}">Luma Only</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MotionSearchLevel" IsChecked="{Binding Path=MotionEstimation.MotionSearchLevel, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=1}">Luma w/ nearest int chroma</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MotionSearchLevel" IsChecked="{Binding Path=MotionEstimation.MotionSearchLevel, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=2}">Luma w/ true chroma</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MotionSearchLevel" IsChecked="{Binding Path=MotionEstimation.MotionSearchLevel, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=3}">Macroblock adaptive w/ nearest int chroma</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MotionSearchLevel" IsChecked="{Binding Path=MotionEstimation.MotionSearchLevel, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=4}">Macroblock adaptive w/ true chroma</RadioButton>
                    </WrapPanel>
                    
                    <TextBlock Grid.Column="0" Grid.Row="2" Margin="0,0,10,2">Motion Search Method</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="2" Margin="0,0,0,2">
                        <RadioButton HorizontalAlignment="Center" GroupName="MotionSearchMethod" IsChecked="{Binding Path=MotionEstimation.MotionSearchMethod, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=0}">SAD</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MotionSearchMethod" IsChecked="{Binding Path=MotionEstimation.MotionSearchMethod, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=1}">Hadamard</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MotionSearchMethod" IsChecked="{Binding Path=MotionEstimation.MotionSearchMethod, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=2}">Macroblock adaptive</RadioButton>
                    </WrapPanel>
                    
                    <TextBlock Grid.Column="0" Grid.Row="3" Margin="0,0,10,2">Macroblock Mode Cost</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="3" Margin="0,0,0,2">
                        <RadioButton HorizontalAlignment="Center" GroupName="MBModeCost" IsChecked="{Binding Path=MotionEstimation.MacroblockModeCost, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=0}">SAD/Hadamard</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MBModeCost" IsChecked="{Binding Path=MotionEstimation.MacroblockModeCost, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=1}">RD cost</RadioButton>
                    </WrapPanel>
                    
                    <TextBlock Grid.Column="0" Grid.Row="4" Margin="0,0,10,2">Motion Vector Cost</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="4" Margin="0,0,0,2">
                        <RadioButton HorizontalAlignment="Center" GroupName="MVCost" IsChecked="{Binding Path=MotionEstimation.MotionVectorCost, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=0}">Static</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MVCost" IsChecked="{Binding Path=MotionEstimation.MotionVectorCost, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=1}">Dynamic</RadioButton>
                    </WrapPanel>
                    
                    <TextBlock Grid.Column="0" Grid.Row="5" Margin="0,0,10,2">Motion Vector Range</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="5" Margin="0,0,0,2">
                        <RadioButton HorizontalAlignment="Center" GroupName="MVRange" IsChecked="{Binding Path=MotionEstimation.MotionVectorRange, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=0}">+63.75/-64.0 H, +31.75/-32.0V</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MVRange" IsChecked="{Binding Path=MotionEstimation.MotionVectorRange, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=1}">+127.75/-128.0 H, +63.75/-64.0 V</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MVRange" IsChecked="{Binding Path=MotionEstimation.MotionVectorRange, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=2}">+511.75/-512.0 H, +127.75/-128.0 V</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MVRange" IsChecked="{Binding Path=MotionEstimation.MotionVectorRange, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=3}">+1023.75/-1024.0 H, +255.75/-256.0 V</RadioButton>
                        <RadioButton HorizontalAlignment="Center" GroupName="MVRange" IsChecked="{Binding Path=MotionEstimation.MotionVectorRange, Converter={StaticResource RadioCheckedConverter}, ConverterParameter=4}">Macroblock adaptive</RadioButton>
                    </WrapPanel>
                </Grid>
            </Expander>
            <Expander Header="Filters" IsExpanded="False">
                <WrapPanel Orientation="Horizontal" Margin="2,0,0,0">
                    <CheckBox x:Name="x_InLoopFilterCheck" IsChecked="{Binding Filters.UseInLoop}">In Loop</CheckBox>
                    <CheckBox x:Name="x_MedianFilterCheck" IsChecked="{Binding Filters.UseMedian}">Median</CheckBox>
                    <CheckBox x:Name="x_DenoiseFilterCheck" IsChecked="{Binding Filters.UseDenoise}">Denoise</CheckBox>
                    <CheckBox x:Name="x_OverlapSmoothingFilterCheck" IsChecked="{Binding Filters.UseOverlapSmoothing}">Overlap Smoothing</CheckBox>
                    <CheckBox x:Name="x_NoiseEdgeFilterCheck" IsChecked="{Binding Filters.UseNoiseEdgeRemoval}">Noise Edge Removal</CheckBox>
                </WrapPanel>
            </Expander>
            <Expander Header="Quantization" IsExpanded="False">
                <Grid Margin="2,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    
                    <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,0,2">Adaptive Quantization</TextBlock>
                    <Slider Grid.Row="0" Grid.Column="1" x:Name="x_AdaptiveQuantSlider" Margin="0,0,0,2" Minimum="0" Maximum="20" Value="{Binding Quantization.AdaptiveQuantization}" />
                    
                    <TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,0,2">Differential Quantization</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Margin="0,0,0,2">
                        <RadioButton GroupName="DQuantOption" x:Name="x_NotUsedRadio" IsChecked="True">Not Used</RadioButton>
                        <RadioButton GroupName="DQuantOption" x:Name="x_IFrameOnly">Only I-frames</RadioButton>
                        <RadioButton GroupName="DQuantOption" x:Name="x_IPFrames">I-frames &amp; P-frames</RadioButton>
                        <RadioButton GroupName="DQuantOption" x:Name="x_IPBFrames">I, P, &amp; B-frames</RadioButton>
                    </WrapPanel>
                    
                    <TextBlock Grid.Row="2" Grid.Column="0" Margin="0,0,0,2">P Frame Perceptual Optimization Strength</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1" Margin="0,0,0,2">
                        <RadioButton GroupName="DQuantPStrength" x:Name="x_NoPStrength" IsChecked="True">Off</RadioButton>
                        <RadioButton GroupName="DQuantPStrength" x:Name="x_OnePStrength">Strong</RadioButton>
                        <RadioButton GroupName="DQuantPStrength" x:Name="x_TwoPStrength">Very Strong</RadioButton>                        
                    </WrapPanel>

                    <TextBlock Grid.Row="3" Grid.Column="0" Margin="0,0,0,2">B Frame Perceptual Optimization Strength</TextBlock>
                    <WrapPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="1" Margin="0,0,0,2">
                        <RadioButton GroupName="DQuantBStrength" x:Name="x_NoBStrength" IsChecked="True">Off</RadioButton>
                        <RadioButton GroupName="DQuantBStrength" x:Name="x_OneBStrength">Strong</RadioButton>
                        <RadioButton GroupName="DQuantBStrength" x:Name="x_TwoBStrength">Very Strong</RadioButton>
                    </WrapPanel>
                </Grid>
            </Expander>        
        </StackPanel>

        <ProgressBar Grid.Row="4" Height="20" x:Name="x_EncodeProgress" Minimum="0" Maximum="100" Value="0" Margin="0,0,0,10" />
        <DockPanel Grid.Row="5">
            <Button DockPanel.Dock="Left" Width="200" x:Name="x_CancelButton" Click="x_CancelButton_Click" IsEnabled="False">Cancel</Button>
            <Button DockPanel.Dock="Right" HorizontalAlignment="Right" Width="200" x:Name="x_EncodeButton" Click="x_EncodeButton_Click">Encode</Button>
        </DockPanel>
    </Grid>
</Window>
